package com.jsu.collegestudentadmissionsystem.service.Impl;

import com.jsu.collegestudentadmissionsystem.dao.StudentDao;
import com.jsu.collegestudentadmissionsystem.pojo.vo.*;
import com.jsu.collegestudentadmissionsystem.service.StudentService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class StudentServiceImpl implements StudentService {

    @Autowired
    StudentDao studentDao;

    @Override
    public void searchStudentList(){
        List<StudentList> studentLists = studentDao.searchStudentList();
        Integer i;
        for(i=0;i<studentLists.size();i++){ System.out.println(studentLists.get(i)); }
    }

    public void queryStudentInfo(Integer studentId) {
        List<StudentInformation> studentInfo = studentDao.queryStudentInfo(studentId);
        Integer i;
        for(i=0;i<studentInfo.size();i++){ System.out.println(studentInfo.get(i)); }
    }

//    @Override
//    public void queryStudentCourseInfo(Integer studentId) {
//        List<StudentInformation> studentInfo = studentDao.queryStudentCourseInfo(studentId);
//        Integer i;
//        for(i=0;i<studentInfo.size();i++){ System.out.println(studentInfo.get(i)); }
//    }

    public void insertStudentInfo(Integer studentId,String stuName,String gender,String birthday,String householdRegistration){
        studentDao.insertStudentInfo(studentId,stuName,gender,birthday,householdRegistration);
    }

    @Override
    public void selectExamSubjects(Integer studentId, String first, String second, String third){
        studentDao.selectExamSubjects(studentId,first,second,third);
    }

    @Override
    public void searchSubjects(Integer studentId){
        List<StudentSubjectInformation> SubjectInfo = studentDao.searchSubjects(studentId);
        Integer i;
        for(i=0;i<SubjectInfo.size();i++){ System.out.println(SubjectInfo.get(i)); }
    }

    @Override
    public void searchScoreRank(Integer studentId){
        List<StudentScoreInformation> ScoreRank = studentDao.searchScoreRank(studentId);
        Integer i;
        if (ScoreRank.size() == 0) {
            System.out.println("\\    \\    \\     \\     \\    \\    \\     \\");
        }
        for(i=0;i<ScoreRank.size();i++){ System.out.println(ScoreRank.get(i)); }
    }

    public void searchEnrollmentInfo(Integer studentId) {
        List<StudentAdmission> EnrollmentInfo =studentDao.searchEnrollmentInfo(studentId);
        if(EnrollmentInfo.size()==0) System.out.println("抱歉，你没有被任何院校录取");
        else {
            Integer i;
            for(i=0;i<EnrollmentInfo.size();i++){ System.out.println(EnrollmentInfo.get(i)); }
        }
    }

    private void printfCollegeInfo(List<CollegeInformation> CollegeInfo){
        Integer i;
        if(CollegeInfo.size()==0) {
            System.out.println("未查询到相关院校");
        }
        for(i=0;i<CollegeInfo.size();i++){
            System.out.println(CollegeInfo.get(i));
        }
    }

    @Override
    public void searchCollegeInfoByBath(Integer bath){
        List<CollegeInformation> CollegeInfo = studentDao.searchCollegeInfoByBath(bath);
        printfCollegeInfo(CollegeInfo);
    }

    @Override
    public void searchCollegeInfoByName(String name){
        List<CollegeInformation> CollegeInfo = studentDao.searchCollegeInfoByName(name);
        printfCollegeInfo(CollegeInfo);
    }

    public void searchCollegeInfoByCode(String code){
        List<CollegeInformation> CollegeInfo = studentDao.searchCollegeInfoByCode(code);
        printfCollegeInfo(CollegeInfo);
    }

    public void searchCollegeMajorInfo(String str){
        List<CollegeMajorInfo> collegeMajorInfoList = studentDao.searchCollegeMajorInfo(str);
        Integer i;
        if(collegeMajorInfoList.size()==0) System.out.println("未查询到该院校的专业信息");
        for(i=0;i<collegeMajorInfoList.size();i++){ System.out.println(collegeMajorInfoList.get(i)); }
    }

    public void searchStudentChoiceList(Integer studentId){
        List<StudentChoiceInfo> studentChoiceInfos = studentDao.searchStudentChoiceList(studentId);
        Integer i;
        if(studentChoiceInfos.size()==0) System.out.println("未查询到志愿信息");
        for(i=0;i<studentChoiceInfos.size();i++){ System.out.println(studentChoiceInfos.get(i)); }
    }

    public void deleteStudentChoice(Integer studentId,Integer collegePriority,Integer majorPriority){
        studentDao.deleteStudentChoice(studentId,collegePriority,majorPriority);
    }

    public void fillStudentChoice(Integer studentId,String collegeCode,String majorCode,Integer collegePriority,Integer majorPriority){
        Integer collegeMajorId = studentDao.queryCollegeMajorId(collegeCode,majorCode);
        System.out.println(collegeMajorId);
        studentDao.fillStudentChoice(studentId,collegeMajorId,collegePriority,majorPriority);
    }


}

